package com.liuqi.loggers.core.filter;

import com.liuqi.loggers.core.AbstractMatcherFilter;
import com.liuqi.loggers.core.FilterReply;
import com.liuqi.loggers.core.Level;
import com.liuqi.loggers.core.LoggerEvent;

/**
 * 过滤低于阈值级别的日志
 *
 * @author liuqi
 * @date 2024/11/5 17:00
 **/
public class ThresholdFilter extends AbstractMatcherFilter {

    Level level;

    @Override
    public FilterReply decide(LoggerEvent event) {
        if (level.ordinal() >= event.getLevel().ordinal()) {
            return onMatch;
        } else {
            return onMismatch;
        }
    }

    public void setLevel(Level level) {
        this.level = level;
    }

}
